
#include "widget.h"
#include "./ui_widget.h"
#include "gamedefine.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setFixedSize(GameDefine::ScreenWidth,GameDefine::ScreenHeight);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::keyPressEvent(QKeyEvent *event)
{
    //添加对应按键组合
    switch(event->key()){
    case Qt::Key_S:
    case Qt::Key_D:
    case Qt::Key_J:
    case Qt::Key_K:
        mKeyList.append(event->key());
        break;
    }
}

void Widget::keyReleaseEvent(QKeyEvent *event)
{
    //移除对应按键组合
    if(mKeyList.contains(event->key())){
        mKeyList.removeOne(event->key());
    }
}
